﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using XiaoGang.Soft.XGWMS.COM;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M013_STORAGEOUTPUT
    {
        /// <summary>
        /// <p><b>メソッド名:</b>GetSingleData</p>	
        /// <p><b>概要説明  :</b>取得单条库存信息</p>
        /// <p><b>作成者    :</b>赫強</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修正履歴  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">检索条件</param>
        /// <returns type = "ReturnValue">检索结果表</returns>
        public ReturnValue GetSingleData(MODEL.MOD_M009_STORAGE model)
        {
            SqlParameter parameter = new SqlParameter("@STORAGE_ID", SqlDbType.Char, 12);
            parameter.Value = model.STORAGE_ID.Trim();
            return XGWMS.DBUtility.SqlHelper.Query(DAL_SQL.DAL_M013_STORAGEOUTPUT_SQL.Get_Single_Data_SQL, parameter);
        }

        /// <summary>
        /// <p><b>メソッド名:</b>GetSingleGoods</p>	
        /// <p><b>概要説明  :</b>取得特定仓库的特定商品信息</p>
        /// <p><b>作成者    :</b>赫強</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修正履歴  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">检索条件</param>
        /// <returns type = "ReturnValue">检索结果表</returns>
        public ReturnValue GetSingleGoods(MODEL.MOD_M009_STORAGE model)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@GOODS_ID", SqlDbType.Char,12),
					new SqlParameter("@STOREROOM_ID", SqlDbType.Char,12)};
            parameters[0].Value = model.GOODS_ID;
            parameters[1].Value = model.STOREROOM_ID;
            return XGWMS.DBUtility.SqlHelper.Query(DAL_SQL.DAL_M013_STORAGEOUTPUT_SQL.Get_Single_Goods_SQL, parameters);
        }

        /// <summary>
        /// <p><b>メソッド名:</b>GetSingleGoods</p>	
        /// <p><b>概要説明  :</b>特定仓库的特定商品数量的更新</p>
        /// <p><b>作成者    :</b>赫強</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修正履歴  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">更新信息</param>
        /// <returns type = "ReturnValue">执行结果信息</returns>
        public ReturnValue SubGoodsCount(MODEL.MOD_M009_STORAGE model)
        {
            SqlParameter[] parameters = {					
					new SqlParameter("@TRANS_STATE", SqlDbType.Char,1),					
					new SqlParameter("@GOODS_ID", SqlDbType.Char,12),					
					new SqlParameter("@UNITS", SqlDbType.Int,4)};
            parameters[0].Value = model.TRANS_STATE;
            parameters[1].Value = model.GOODS_ID;
            parameters[2].Value = model.UNITS;

            return XGWMS.DBUtility.SqlHelper.ExecuteSql(DAL_M013_STORAGEOUTPUT_SQL.Sub_Goods_Count_SQL, parameters);
        }

        /// <summary>
        /// <p><b>メソッド名:</b>InsertProcess</p>	
        /// <p><b>概要説明  :</b>货单的插入</p>
        /// <p><b>作成者    :</b>赫強</p>	
        /// <p><b>作成日    :</b>2008/09/09</p>	
        /// <p><b>修正履歴  :</b></p>	
        /// </summary>
        /// <param type="class" name="model">货单信息</param>
        /// <returns type = "ReturnValue">执行结果信息</returns>
        public ReturnValue InsertProcess(MODEL.MOD_M009_STORAGE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.AppendFormat(" INSERT INTO [M009_STORAGE]( {0}", (char)13);
            strSql.AppendFormat("      [CREATE_DATETIME]                  {0}", (char)13);
            strSql.AppendFormat("     ,[UPDATE_DATETIME]                  {0}", (char)13);
            strSql.AppendFormat("     ,[TRANS_STATE]                      {0}", (char)13);
            strSql.AppendFormat("     ,[UPDATER_ID]                       {0}", (char)13);
            strSql.AppendFormat("     ,[TERMINAL_CD]                      {0}", (char)13);
            strSql.AppendFormat("     ,[STORAGE_ID]                       {0}", (char)13);
            strSql.AppendFormat("     ,[STOREROOM_ID]                     {0}", (char)13);
            strSql.AppendFormat("     ,[GOODS_ID]                         {0}", (char)13);
            strSql.AppendFormat("     ,[UNITS]                            {0}", (char)13);
            strSql.AppendFormat("     ,[MEMO]                             {0}", (char)13);
            strSql.AppendFormat(" )VALUES(                                {0}", (char)13);
            strSql.AppendFormat("      CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','') {0}", (char)13);
            strSql.AppendFormat("     ,CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','') {0}", (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.TRANS_STATE, (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.UPDATER_ID, (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.TERMINAL_CD, (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.STORAGE_ID, (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.STOREROOM_ID, (char)13);
            strSql.AppendFormat("     ,'{0}' {1}", model.GOODS_ID, (char)13);
            strSql.AppendFormat("     , {0}  {1}", model.UNITS, (char)13);
            strSql.AppendFormat("     ,'{0}'){1}", model.MEMO, (char)13);

            return XGWMS.DBUtility.SqlHelper.Query(strSql.ToString());
        }
    }
}
